Spanish updates from Alberto Nu~nez
[adiumx.git] / Plugins / Purple Service / ESPurpleYahooAccountViewController.m
blob918faca6174e58c6fb2280a6832f3073f671c185
1 /* 
2  * Adium is the legal property of its developers, whose names are listed in the copyright file included
3  * with this source distribution.
4  * 
5  * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6  * General Public License as published by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
11  * Public License for more details.
12  * 
13  * You should have received a copy of the GNU General Public License along with this program; if not,
14  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15  */
17 #import "ESPurpleYahooAccountViewController.h"
18 #import "ESPurpleYahooAccount.h"
19 #import <Adium/AIAccount.h>
20 #import <AIUtilities/AIPopUpButtonAdditions.h>
21 #import <AIUtilities/AIMenuAdditions.h>
23 @interface ESPurpleYahooAccountViewController (PRIVATE)
24 - (NSMenu *)chatServerMenu;
25 @end
27 @implementation ESPurpleYahooAccountViewController
29 /*!
30  * @brief Nib name
31  */
32 - (NSString *)nibName{
33     return @"ESPurpleYahooAccountView";
36 /*!
37  * @brief Awake from nib
38  */
39 - (void)awakeFromNib
41         [super awakeFromNib];
42         [popUp_chatServer setMenu:[self chatServerMenu]];
45 /*!
46  * @brief Configure controls
47  */
48 - (void)configureForAccount:(AIAccount *)inAccount
50         [super configureForAccount:inAccount];
52         [popUp_chatServer selectItemWithRepresentedObject:[inAccount preferenceForKey:KEY_YAHOO_ROOM_LIST_LOCALE
53                                                                                                                                                         group:GROUP_ACCOUNT_STATUS]];
56 /*!
57  * @brief Save controls
58  */
59 - (void)saveConfiguration
61     [super saveConfiguration];
62         
63         [account setPreference:[[popUp_chatServer selectedItem] representedObject]
64                                         forKey:KEY_YAHOO_ROOM_LIST_LOCALE
65                                          group:GROUP_ACCOUNT_STATUS];
68 - (NSMenu *)chatServerMenu
70         NSMenu                  *chatServerMenu = [[NSMenu allocWithZone:[NSMenu zone]] init];
71         NSMutableArray  *menuItems = [NSMutableArray array];
72         NSMenuItem              *menuItem;
73         NSEnumerator    *enumerator;
74         NSString                *prefix;
75         NSDictionary    *roomListServersDict;
77         roomListServersDict = [NSDictionary dictionaryWithObjectsAndKeys:
78                 @"Asia", @"aa",
79                 @"Argentina", @"ar",
80                 @"Australia", @"au",
81                 @"Brazil", @"br",
82                 @"Canada", @"ca",
83                 @"Central African Republic", @"cf",
84                 @"China", @"cn",
85 /*              @"Germany", @"de",*/
86                 @"Denmark", @"dk",
87                 @"Spain", @"es",
88                 @"France", @"fr",
89                 @"Hong Kong", @"hk",
90                 @"India", @"in",
91                 @"Italy", @"it",
92                 @"Korea, Republic of", @"kr",
93                 @"Mexico", @"mx",
94                 @"Norway", @"no",
95                 @"Sweden", @"se",
96                 @"Singapore", @"sg",
97                 @"Taiwan", @"tw",
98                 @"United Kingdom", @"uk",
99                 nil];
101         menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"United States",nil)
102                                                                                                                                          target:nil
103                                                                                                                                          action:nil
104                                                                                                                           keyEquivalent:@""] autorelease];
105         [menuItem setRepresentedObject:@"us"];
106         [menuItems addObject:menuItem];
108         enumerator = [roomListServersDict keyEnumerator];
109         while ((prefix = [enumerator nextObject])) {
110                 menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:[roomListServersDict objectForKey:prefix]
111                                                                                                                                                  target:nil
112                                                                                                                                                  action:nil
113                                                                                                                                   keyEquivalent:@""] autorelease];
114                 [menuItem setRepresentedObject:prefix];
115                 [menuItems addObject:menuItem];         
116         }
118         [menuItems sortUsingSelector:@selector(titleCompare:)];
120         enumerator = [menuItems objectEnumerator];
121         while ((menuItem = [enumerator nextObject])) {
122                 [chatServerMenu addItem:menuItem];
123         }
125         return [chatServerMenu autorelease];
128 @end